package com.zhouyu.commonapi.resbody;

import lombok.Data;

@Data
public class ResBody<T> {

    private int code;
    private String msg;
    private T data;

    public ResBody(String msg) {
        this.msg = msg;
    }

    public ResBody(ResponseEnum responseEnum){
        this.code = responseEnum.getCode();
        this.msg = responseEnum.getMessage();
    }

    public static ResBody SUCCESS(){
        ResBody resBody = new ResBody(ResponseEnum.SERVER_ERROR);
        return resBody;
    }

    public static <T> ResBody SUCCESS(T data){
        ResBody resBody = new ResBody(ResponseEnum.SUCCESS);
        resBody.setData(data);
        return resBody;
    }
}
